<template>
	
	<view style="height: 100vh;background: #fff;">
		
		
		<u-grid :border="false" col="5">
			<u-grid-item v-for="(listItem,listIndex) in cateList" :key="listIndex" 
				@click="clickFood(listItem)">
				<image class="icon" :src="listItem.logo_image"></image>
				<text class="grid-text">{{listItem.name}}</text>
			</u-grid-item>
		</u-grid>
	</view>
</template>

<script>
	import store from '@/shopro/store/index.js'
	
	export default {
		data() {
			return {
				cateId: "",
				cateList: []
			}
		},
		onLoad(options) {
			console.log(options, getCurrentPages()[0].options, "options")
			this.cateId = options ? options.id : getCurrentPages()[0].options.id
			this.getCate()
		},
		methods: {
			getCate() {
				console.log("getCate begin")
				var that = this;
				that.$https('category.getCateByType', {
					token: uni.getStorageSync("token"),
					type_id: this.cateId
				}).then(res => {
					this.cateList = res.data.cate
				})
			},
			goback() {
				uni.navigateBack({
					delta: 1
				});				
			},
			clickFood(e) {
				console.log('e', e)
				console.log("token",uni.getStorageSync("token"))
				if(uni.getStorageSync("token") ===""){
					uni.showModal({
						content: '该店铺为企业类店铺 \n\r 成为会员才能查看哦！',
						cancelText: '取消',
						confirmText: '成为会员',
						success: res => {
							if (res.confirm) {
								store.dispatch('showAuthModal','toLogins');
								
							}
						}
					});
				}else{
					uni.navigateTo({
						url: '/pages/index/food?store_cate_id=' + e.store_type_id + "&title=" + e.name
					})
				}
				
			},
		}
	}
</script>

<style lang="scss" scoped>
	.icon {
		width: 72rpx;
		height: 72rpx;
	}
	.grid-text{
		margin-top: 20rpx;
		font-size: 12px;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #666666;
		line-height: 14px;
	}
</style>
